package orbito.physics.motion;

import orbito.util.SimUtils;
import orbito.util.Vec2;

public class State {
	Vec2 x, v;
	double a, w;
	
	public State(State state) {
		this(new Vec2(state.x), new Vec2(state.v), 0.0, 0.0);
	}
	
	public State(Vec2 position, Vec2 velocity, double orientation, double angularSpeed) {
		this.x = position;
		this.v = velocity;
		this.a = orientation;
		this.w = angularSpeed;
	}
	
	public static State lerp(State a, State b, double factor) {
		return new State(
				Vec2.lerp(a.x, b.x, factor),
				Vec2.lerp(a.v, b.v, factor),
				SimUtils.lerp(a.a, b.a, factor),
				SimUtils.lerp(a.w, b.w, factor));
	}
	
	public static class Derivative {
		Vec2 dx, dv;
		double da, dw;
		
		public Derivative(Vec2 dx, Vec2 dv, double da, double dw) {
			this.dx = dx;
			this.dv = dv;
			this.da = da;
			this.dw = dw;
		}
	}
}
